﻿using System;

namespace Little.Soldier.SWIFT.Definition
{
  [Serializable]
  internal class SwiftTagChoiceDefinition : SwiftDefinitionElement
  {
    private bool _multiple;

    public bool Multiple
    {
      get
      {
        return this._multiple;
      }
      set
      {
        this._multiple = value;
      }
    }

    public SwiftTagChoiceDefinition()
    {
    }

    public SwiftTagChoiceDefinition(string name, string description)
      : base(name, description)
    {
    }

    public override void U008E(SwiftDefinitionElement element)
    {
      if (element is SwiftTagSubItemDefinition)
        throw new InvalidOperationException("SwiftTagChoice cannot contain SwiftTagSubItem elements");
      base.U008E(element);
    }

    public override bool U008F(object obj)
    {
      SwiftTagChoiceDefinition choiceDefinition = obj as SwiftTagChoiceDefinition;
      if (choiceDefinition == null || this._multiple != choiceDefinition.Multiple)
        return false;
      else
        return base.U008F(obj);
    }
  }
}
